package com.yyj.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.yyj.dto.CyRoomDto;
import com.yyj.entity.PageResult;
import com.yyj.service.CyRoomService;
import com.yyj.mapper.CyRoomMapper;
import com.yyj.entity.CyRoom;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * @author 汪彬彬
 * @since 2025-03-29 19:41:13
 */
@Service
@Slf4j
public class CyRoomServiceImpl implements CyRoomService{

    @Autowired
    private CyRoomMapper cyRoomMapper;

    @Override
    public PageResult<CyRoom> findPage(CyRoomDto params) {
        Page<CyRoom> page = PageHelper.startPage(params);
        List<CyRoom> list = cyRoomMapper.findPage(params);
        PageResult<CyRoom> pageResult = new PageResult<>();
        pageResult.setContent(list);
        pageResult.setTotalElements(page.getTotal());
        return pageResult;
    }

    @Override
    public List<CyRoom> findList(CyRoom params) {
        return cyRoomMapper.findList(params);
    }

    @Override
    public CyRoom findById(Long id) {
        return cyRoomMapper.findById(id);
    }

    @Override
    public int insert(CyRoom cyRoom) {
        return cyRoomMapper.insert(cyRoom);
    }

    @Override
    public int update(CyRoom cyRoom) {
        return cyRoomMapper.update(cyRoom);
    }

    @Override
    public int delete(Long id) {
        return cyRoomMapper.delete(id);
    }

}